package org.example.novel.utlis;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    private Integer code;

    private String msg;

    private T data;

    public static<T> Result<T> success(){
        return new Result<>(200,"操作成功",null);
    }

    public static<T> Result<T> success(String msg,T data){
        return new Result<>(200,msg,data);
    }

    public static<T> Result<T> success(T data){
        return new Result<>(200,"操作成功",data);
    }

    public static<T> Result<T> fail(){
        return new Result<>(500,"操作失败",null);
    }

    public static<T> Result<T> fail(String msg){
        return new Result<>(500,msg,null);
    }

    public static<T> Result<T> fail(Integer code,String msg){
        return new Result<>(code,msg,null);
    }

}
